package com.ruoyi.back.controller

import com.ruoyi.app.common.Data
import com.ruoyi.back.domain.v2.Task
import com.ruoyi.back.domain.v2.TaskCodeShare
import com.ruoyi.back.domain.v2.TaskShare
import com.ruoyi.back.service.TaskService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("system/task")
@Api(tags = ["任务管理"])
class TaskController {

    @Autowired
    private lateinit var taskService: TaskService

    @ApiOperation("编辑任务")
    @PostMapping("updateTask")
    fun updateTask(@RequestBody task: Task): Data<Boolean> = taskService.updateTask(task)

    @ApiOperation("任务分享设置")
    @PostMapping("taskShareSetting")
    fun taskShareSetting(@RequestBody taskShare: TaskShare): Data<Boolean> = taskService.taskShareSetting(taskShare)

    @ApiOperation("文案图分享设置")
    @PostMapping("taskCodeShareSetting")
    fun taskCodeShareSetting(@RequestBody taskCodeShare: TaskCodeShare): Data<Boolean> =
        taskService.taskCodeShareSetting(taskCodeShare)


    @ApiOperation("任务列表")
    @GetMapping("taskList")
    fun taskList(channelType: Int): Data<List<Task>> = taskService.taskList(channelType)

    @ApiOperation("任务分享")
    @GetMapping("taskShare/{taskId}")
    fun taskShare(@PathVariable taskId: Long): Data<TaskShare> = taskService.taskShare(taskId)

    @ApiOperation("文案图分享")
    @GetMapping("taskCodeShare/{taskId}")
    fun taskCodeShare(@PathVariable taskId: Long): Data<TaskCodeShare> = taskService.taskCodeShare(taskId)
}